They are in the diagram. 2k, 2k, 330, 330, in series. Then 2k, 220 in series. I realized I had the voltage divider backwards (5-1.6 =3.4) lol. So it should work now.
i already have the old one set up but using it i still get no output with your code
Have you tried sketch of #16? Are you using active or passive voltage divider?
yes the setup in post 17 is following the schematic and using the code from post 16. Any ideas what to try next? i have an oscilloscope with me if needed.
passive voltage divider to lower the signal voltage
1. Resistor setup of #17 is dubious. Please, make clean setup using few resistors possible as per Fig-1.
Figure-1:
2. Upload the following sketch (active upload mode):
#include<SoftwareSerial.h>
SoftwareSerial SUART(5, 6);
byte myData[13];
void setup()
{
Serial.begin(9600);
SUART.begin(9600);
//-------active upload mode---------
uint8_t autoCmd[9] = {0xFF, 0x01, 0x78, 0x40, 0x00, 0x00, 0x00, 0x00, 0x47};
for (byte i = 0; i < 9; i++)
{
SUART.write(autoCmd[i]);
}
}
void loop()
{
//----read gas, temp, humidity data-------------
byte y = SUART.available();
if (y != 0)
{
byte m = SUART.readBytes(myData, 13);
if (m == 13) //13-byte data hasve arrived
{
if (myData[0] == 0xFF && myData[1] == 0x87) //Header AND Command ID
{
int rawTemp = (myData[8] << 8) | myData[9];
int rawHum = (myData[10] << 8) | myData[11];
float temp = rawTemp / 10.0;
float hum = rawHum / 10.0;
Serial.print("Temperature: ");
Serial.print(temp, 1);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(hum, 1);
Serial.println(" %RH");
Serial.println("------------------------");
delay(1000);
}
}
}
}
3. Connect oscope at DPin-5 of UNO.
4. Check if the oscope shows pulse activites (there are Highs and Lows).
i added a delay between the command and reading the response and it works now. Thanks to everyone for the help!
Post the sketch and the readings of Serial Monitor.
#include<SoftwareSerial.h>
SoftwareSerial SUART(5, 6);
byte myData[13];
void setup()
{
Serial.begin(9600);
SUART.begin(9600);
//-------passive mode---------
uint8_t autoCmd[9] = {0xFF, 0x01, 0x78, 0x41, 0x00, 0x00, 0x00, 0x00, 0x46};
for (byte i = 0; i < 9; i++)
{
SUART.write(autoCmd[i]);
}
Serial.println("Sent passive mode command");
}
void loop()
{
//---- read command--------
uint8_t gthReadCmd[9] = {0xFF, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};
for (byte i = 0; i < 9; i++)
{
SUART.write(gthReadCmd[i]);
}
// Wait for response (up to 500 ms)
unsigned long start = millis();
while (SUART.available() < 13 && (millis() - start) < 500) {
// just waiting
}
//----read gas, temp, humidity data-------------
byte y = SUART.available();
if (y != 0)
{
byte m = SUART.readBytes(myData, 13);
if (m == 13) //13-byte data have arrived
{
if (myData[0] == 0xFF && myData[1] == 0x87) //Frame Header AND Command ID
{
int rawTemp = (myData[8] << 8) | myData[9];
int rawHum = (myData[10] << 8) | myData[11];
int ox = ((myData[6] * 256 + myData[7]));
float temp = rawTemp / 100.0;
float hum = rawHum / 100.0;
Serial.print("Temperature: ");
Serial.print(temp, 1);
Serial.println(" °C");
Serial.print("Humidity: ");
Serial.print(hum, 1);
Serial.println(" %RH");
Serial.print("Oxygen: ");
Serial.print(ox, 1);
Serial.println(" ppb");
Serial.println("------------------------");
delay(1000);
}
}
}
}
realized my oxygen level is off by 100,000. i can’t multiply by 100,000 or it goes over int cap i think. should i make it a long?
Congratulations!
Last follow up. If I wanna run this with no breadboard at all, just wires straight from the arduino to the sensor, is there an arduino model that works on 3.3v logic and has usb connectivity? Would the arduino nano work to this capacity? If not why not?
whats the advantage with this over the arduino MKR board for example. Can i still program it using the arduino IDE?
1. I have no idea on MKR Board.
2. You can program ESP32 using Arduino IDE in the same way you do for UNOR3.
3. ESP32 as built-in WiFi, Bluetooth, ADC, DAC etc.
4. The attached file may give you an introduction on ESP32.
ch-18 ESP32Lec.pdf (1.2 MB)


