So I have connected a SparkFun Triad Spectroscopy Sensor - AS7265x (Qwiic) to my SparkFun Thing Plus - ESP32-S2 WROOM using a Qwiic cable. I loaded the example code and I am only getting zeros from the sensors... No error, it throws a connection error when disconnected, just this image as the output over the serial monitor. https://imgur.com/a/OpC5hij
/*
Read the 18 channels of spectral light over I2C using the Spectral Triad
By: Nathan Seidle
SparkFun Electronics
Date: October 25th, 2018
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example takes all 18 readings and blinks the illumination LEDs
as it goes. We recommend you point the Triad away from your eyes, the LEDs are *bright*.
Feel like supporting open source hardware?
Buy a board from SparkFun! https://www.sparkfun.com/products/15050
Hardware Connections:
Plug a Qwiic cable into the Spectral Triad and a BlackBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/
#include "SparkFun_AS7265X.h" //Click here to get the library: http://librarymanager/All#SparkFun_AS7265X
AS7265X sensor;
#include <Wire.h>
void setup()
{
Serial.begin(115200);
Serial.println("AS7265x Spectral Triad Example");
Serial.println("Point the Triad away and press a key to begin with illumination...");
while (Serial.available() == false)
{
} //Do nothing while we wait for user to press a key
Serial.read(); //Throw away the user's button
if (sensor.begin() == false)
{
Serial.println("Sensor does not appear to be connected. Please check wiring. Freezing...");
while (1)
;
}
sensor.disableIndicator(); //Turn off the blue status LED
Serial.println("A,B,C,D,E,F,G,H,R,I,S,J,T,U,V,W,K,L");
}
void loop()
{
sensor.takeMeasurementsWithBulb(); //This is a hard wait while all 18 channels are measured
Serial.print(sensor.getCalibratedA()); //410nm
Serial.print(",");
Serial.print(sensor.getCalibratedB()); //435nm
Serial.print(",");
Serial.print(sensor.getCalibratedC()); //460nm
Serial.print(",");
Serial.print(sensor.getCalibratedD()); //485nm
Serial.print(",");
Serial.print(sensor.getCalibratedE()); //510nm
Serial.print(",");
Serial.print(sensor.getCalibratedF()); //535nm
Serial.print(",");
Serial.print(sensor.getCalibratedG()); //560nm
Serial.print(",");
Serial.print(sensor.getCalibratedH()); //585nm
Serial.print(",");
Serial.print(sensor.getCalibratedR()); //610nm
Serial.print(",");
Serial.print(sensor.getCalibratedI()); //645nm
Serial.print(",");
Serial.print(sensor.getCalibratedS()); //680nm
Serial.print(",");
Serial.print(sensor.getCalibratedJ()); //705nm
Serial.print(",");
Serial.print(sensor.getCalibratedT()); //730nm
Serial.print(",");
Serial.print(sensor.getCalibratedU()); //760nm
Serial.print(",");
Serial.print(sensor.getCalibratedV()); //810nm
Serial.print(",");
Serial.print(sensor.getCalibratedW()); //860nm
Serial.print(",");
Serial.print(sensor.getCalibratedK()); //900nm
Serial.print(",");
Serial.print(sensor.getCalibratedL()); //940nm
Serial.print(",");
Serial.println();
}
I have run the Example "GetVersion" With this output:
AS7265x Spectral Triad Example
AMS Device Type: 0x40
AMS Hardware Version: 0x41
Major Firmware Version: 0xC
Patch Firmware Version: 0x0
Build Firmware Version: 0x0
I just tested using an arduino nano connected over i2c again. Same result as the esp32's all zeros on output in serial. Im at a loss.
This was an environment issue. Ran arduino as portable and fixed....
Related
before to come here, I've tried lot an lot of solutions found on the net and here.
The issue is:
After compile code (passed as good), I try to upload it into ESP8266 throu Arduino.
The result is:
« esptool.py v3.0 Serial port /dev/ttyACM0
Connecting........_____....._____....._____....._____....._____....._____.....____
Traceback (most recent call last):
File "/home/patrick/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/upload.py", line 66, in <module> esptool.main(cmdline)
File "/home/patrick/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 3552, in main esp.connect(args.before, args.connect_attempts)
File "/home/patrick/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 529, in connect raise
FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error)) esptool.
FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
_ le port série sélectionné _ n'existe pas ou votre Arduino n'est pas connecté »
During transfer I can see both Arduino (TX and RX) DEL blinking, and Arduino RX blinks the ESP8266 TX blinks also. From there ... I feel like having good connection.
The pinout goses like this
Arduino - ESP8266
GND - GND
3.3V - VCC
RX+0 - TX
TX+1 - RX
3.3V - CH_PD/EN
According to ESP8266pinout
I tried to
change the upload speed
change the CPU frequency
change the cristal frequency
switch TX / RX just i case I would plugged them on reverse
updated the DHT driver and adapted the code consequently
downgrade the ESP8666 driver on Arduino IDE from 3.2 to 2.5.1, to 2.5.0, to 2.4.9
modify the upload.py file, line 66 and around
My ESP8666 did connect properly to the WiFi Network previously, programming it with Raspberry PICO and micropython. From that, I'm pretty sure about the good working state of the device.
Below is my c++ code
#include <ESP8266WiFi.h>
#include <DHT.h>
const char* ssid = "BullFrog"; // Your ssid
const char* password = "Pr1on$J3sus"; // Your Password
WiFiServer server(80);
//Instantiation d'une nouvelle classe DHT
// DHT DHT (pin, type, count);
// #param pin
// pin number that sensor is connected
// #param type
// type of sensor
// #param count
// number of sensors
DHT DHT(2, 11, 1);
double Fahrenheit(double celsius) {
return ((double)(9 / 5) * celsius) + 32;
}
double Kelvin(double celsius) {
return celsius + 273.15;
}
void setup() {
Serial.begin(115200);
delay(10);
Serial.println();
// Connect to WiFi network
WiFi.mode(WIFI_STA);
Serial.println();
Serial.println();
Serial.print("Tentative de connexion au Wifi nommé ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Connexion WiFi établie");
// Start the server
server.begin();
Serial.println("Démarrage du serveur web");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop() {
int err;
float temp, humi;
if (temp = DHT.readTemperature(false, false)) {
Serial.print("Température:");
Serial.print(temp);
} else {
Serial.println();
Serial.print("Erreur lors de la lecture de la température. No :");
Serial.print(err);
Serial.println();
}
if (temp = DHT.readHumidity(false)) {
Serial.print(" Humidité:");
Serial.print(humi);
Serial.println();
} else {
Serial.println();
Serial.print("Erreur lors de la lecture de l humidité relative. No :");
Serial.print(err);
Serial.println();
}
WiFiClient client = server.available();
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println("Refresh: 5");
client.println();
client.println("<!DOCTYPE html>");
client.println("<html xmlns='http://www.w3.org/1999/xhtml'>");
client.println("<head>\n<meta charset='UTF-8'>");
client.println("<title>ESP8266 Température & Humidité DHT11</title>");
client.println("</head>\n<body>");
client.println("<H2>Capteurs ESP8266 & DHT11</H2>");
client.println("<H3>Humidité / Température</H3>");
client.println("<pre>");
client.print("Humidité (%) : ");
client.println((float)humi, 2);
client.print("Température (°C) : ");
client.println((float)temp, 2);
client.print("Température (°F) : ");
client.println(Fahrenheit(temp), 2);
client.print("Température (°K) : ");
client.println(Kelvin(temp), 2);
client.println("</pre>");
client.println("<H3>Revenez nous voir!</H3>");
client.print("</body>\n</html>");
// delay(DHT11_RETRY_DELAY); //delay for reread
}
I want to use this kit in standalone
I followed this tutorial (among others)
Thanks for your attention and help.
I would first try to program your ESP-01 with a simple Blink sketch, just to confirm the ESP-01 is ok.
These are examples from the same website you reference:
https://www.elec-cafe.com/tag/esp8266-flasher/
https://www.elec-cafe.com/esp8266-esp-01-firmware-update/
Also, the ESP8266 requires a good amount for power for WiFi transmit. Sometimes it help to use separate power supply and add 470uF or 1000uF capacitor across the VCC and GND of the ESP chip.
I hope this might help you to succeed.
The problem is not in coding but in wiring.
Remember that (with ESP8266-01) :
pin 1 as GND (from left to right 1,2,3,4) on the row near to the middle of board
pins 5 as VCC (from right to left 5,6,7,8) on the row near to the ridge of board
pins 5 and 7 must be permanently connected
for loading code into ESP8266-01: pins 1 and 3 must be connected for the uploading time duration.
Once everything is uploaded, come back to the using position (uplug 1 - 3) like this:
I have a DS1302 RTC board (Waveshare) connected to an Arduino uno.
I'm printing time to Arduino's Serial Monitor but I get weird numbers/characters, and after 2-4 seconds it stops printing.
Wiring:
Vcc -> 5v
GND -> GND
I/O (MISO) -> Pin 12
SCLK -> Pin 13
CE (CS) -> Pin 10
Library used: VirtuabotixRTC library.
Things I've tried so far:
I tried a second DS1302 RTC board.
I tried a different Arduino board.
I tried changing the jumper wires.
I tried different baud rates.
Code:
#include <virtuabotixRTC.h>
virtuabotixRTC myRTC(7,8,9);
void setup() {
Serial.begin(9600);
// myRTC.setDS1302Time(30,30,5,5,5,5,2020);
}
void loop() {
myRTC.updateTime();
Serial.print(myRTC.hours);
Serial.print(":");
Serial.print(myRTC.minutes);
Serial.print(":");
Serial.println(myRTC.seconds);
}
Screenshots:
I wrote a sample code for blinking an LED linked to Python. The code is not throwing me any error, but the LED is not blinking. Any suggestions?
Python code:
import serial #import the pyserial library
connected = False #this will represent whether or not ardunio is connected to the system
ser = serial.Serial("COM3",9600) #open the serial port on which Ardunio is connected to, this will coommunicate to the serial port where ardunio is connected, the number which is there is called baud rate, this will provide the speed at which the communication happens
while not connected:#you have to loop until the ardunio gets ready, now when the ardunio gets ready, blink the led in the ardunio
serin = ser.read()
connected = True
ser.write('1') #this will blink the led in the ardunio
while ser.read() == '1': #now once the led blinks, the ardunio gets message back from the serial port and it get freed from the loop!
ser.read()
print('Program is done')
ser.close()
Arduino code:
void setup() {
Serial.begin(9600);
pinMode(10,OUTPUT);
Serial.write('1');
}
void loop() {
if(Serial.available()>0){
digitalWrite(255,HIGH);
delay(50);
digitalWrite(50,LOW);
delay(50);
digitalWrite(255,HIGH);
delay(50);
digitalWrite(50,LOW);
delay(50);
digitalWrite(255,HIGH);
delay(50);
digitalWrite(50,LOW);
Serial.read();
}
else{
Serial.available()==0;
}
}
In the arduino code, you call
digitalWrite(50,LOW);
and
digitalWrite(255,HIGH);
but the first parameter of digitalWrite is the pin number, which you defined as pin 10. Simply change 50 and 255 to 10 as that is where you want your low and high signals to output to.
I am using an A-Star 32U4 Micro Arduino and I'm trying to connect the RDM6300 - 125KHz Cardreader Mini-Module.
I'm using this sketch at the moment:
#include <SoftwareSerial.h>
// RFID | Nano
// Pin 1 | D2
// Pin 2 | D3
SoftwareSerial Rfid = SoftwareSerial(2,3);
void setup() {
// Serial Monitor to see results on the computer
Serial.begin(9600);
// Communication to the RFID reader
Rfid.begin(9600);
}
void loop() {
// check, if any data is available
if(Rfid.available() > 0 ){
// as long as there is data available...
while(Rfid.available() > 0 ){
// read a byte
int r = Rfid.read();
// print it to the serial monitor
Serial.print(r, DEC);
Serial.print(" ");
}
// linebreak
Serial.println();
}
}
With this circuit:
module TX --- Arduino pin 2
module VCC ----- 5v
module ground ---- ground
antenna pins ---- antenna
When I put the card in the sensor nothing shows up on serial port. I tried this setup and the exact same sensors on an Arduino Uno (same sketch) and it worked perfectly, but I cant get this working on the Micro.
Arduino UNO and Micro uses different processors, though they work fairly similarly, they are not totaly identical.
It seams that
not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
From the SoftwareSerial Library description ( https://www.arduino.cc/en/Reference/softwareSerial )
Change the module TX from pin 2 to pin 8. and you should be good. :-)
Side A:
Arduino Uno R3 with Wireless Proto shield powered with USB
With XBee Pro S1, DH 0 DL FFFF MY 0 API 0
Wireless Proto shield has the serial select switch on the 'micro' position
side B:
XBee Explorer USB connected to a PC with XCTU software
With XBee Pro S1, DH 0 DL FFFF MY 0 API 0
(When I put both XBee modules in the USB explorer boards, connected with two PC's, I can send data back and forth without any problems, so I reckon the XBee settings are good.)
The Problem
Now I want the Arduino to capture the input from the B side (send with the XCTU terminal), but when I type anything in the terminal, the RSSI LED on side A just turns on for 5 seconds, but the Arduino does not seem to capture any data since it does not send data back like it should (Serial.print("I received: ");
Arduino sketch:
int incomingByte = 0;
void setup() {
Serial.begin(19200); //Both XBee chips are configured at 19200 Baud
Serial.print("start echo machine"); //This is received just fine on the B side
}
void loop() {
if (Serial.available() > 0) {
// Read the incoming byte:
incomingByte = Serial.read();
// Say what you got:
Serial.print("I received: "); //This never shows on the B-side
Serial.println(incomingByte, DEC);
}
}
How do I fix this problem?
You have to use a SoftwareSerial(RX,TX) for the XBee and the Serial for printing the output into the pc.
RX and TX of SoftwareSerial must be linked to the DOUT and DIN pin of the module into the Wireless Proto shield:
#include <SoftwareSerial.h>
// Connect pin 10 of Arduino to DOUT of Wireless Proto shield
uint8_t ssRX = 10;
// Connect pin 11 of Arduino to DIN of Wireless Proto shield
uint8_t ssTX = 11;
SoftwareSerial nss(ssRX, ssTX);
void setup() {
Serial.begin(19200);
nss.begin(19200);
Serial.println("Serial works");
}
void loop() {
if (nss.available()){
Serial.println("received packet:");
for(int i=0;i<25;i++){
Serial.print(nss.read(),HEX);
Serial.print(",");
}
Serial.println();
}
Many of the boards require the pull-up resistor on DIN to be enabled.
According to some sources this pull-up is enabled by default on the Digi Xbee module.
To ensure it is enabled or to enable it:
Put your Xbee module in a USB explorer and use X-CTU to check the PR configuration.
DIN is on bit 7 for the Xbee Pro S1, so in that case you need the last bit to be 1.
I put it like this: 00000001
Than you convert it to hex (01 in my case) and write that value to the Xbee module with X-CTU.
So it is an electronics issue and not a programming issue.