Hello, I have seen others add an esp8266 or an esp32 on the ikea air sensor. I have had 2 of these before I ever saw this online before. I also wanted to add this feature as well. I figured out the wiring but for the coding they are using tasmota esp home assistant. I'm not using home assistant at all. I wanted to know if anyone has anycode to just read the sensor? I can not find anything people are working on or using without the home assistant on there. Any help in pushing me in the right direction would be great please.
Hello wildbill, That link points is using the esp home assistant with an bin file. I have been through over 300 sites so far and most of them being redirect to that bin file. others to different bin files esp home assistant. But no arduino coding at all.
From what I can see, it reads the sensor and then sends its reading to MQTT for Home assistant to pick up and do whatever it fancies.
I see this being populated with the air quality measure:
state.avgPM25
So I would think that you could hack a version of that code to get that number, forget the MQTT stuff and do your own thing with it. And when I say hack, I mostly mean use the delete key
Not sure what the bin file is, but the Github repository linked to from the Hackaday page looks adaptable for your purposes, though it'll be a little work I expect.
I have found code just now. it looks like it is an 2.5 air sensor. I need to take out all the wifi stuff and mqtt just have the air sensor part in there.
#include "Adafruit_PM25AQI.h"
#include <SoftwareSerial.h>
SoftwareSerial pmSerial(6, 7);
Adafruit_PM25AQI aqi = Adafruit_PM25AQI();
#define pmsDataLen 32
uint8_t buf[pmsDataLen];
int idx = 0;
int pm10 = 0;
int last_pm25 = 0;
int pm25 = 0;
int pm100 = 0;
uint16_t pm25color[] = {
0x9FF3,
0x37E0,
0x3660,
0xFFE0,
0xFE60,
0xFCC0,
0xFB2C,
0xF800,
0x9800,
0xC99F
};
void setup() {
Serial.begin(115200);
while (!Serial) delay(10);
// Wait one second for sensor to boot up!
delay(1000);
pmSerial.begin(9600);
if (! aqi.begin_UART(&pmSerial)) {
Serial.println("Could not find PM 2.5 sensor!");
while (1) delay(10);
}
Serial.println("PM25 found!");
}
void loop() {
PM25_AQI_Data data;
if (! aqi.read(&data)) {
Serial.println("Could not read from AQI");
delay(500); // try again in a bit!
return;
}
// This is used for debugging purposes and to show what additional data could potentially be rendered
Serial.println(F("---------------------------------------"));
Serial.println(F("Concentration Units (standard)"));
Serial.println(F("---------------------------------------"));
Serial.print(F("PM 1.0: ")); Serial.print(data.pm10_standard);
Serial.print(F("\t\tPM 2.5: ")); Serial.print(data.pm25_standard);
Serial.print(F("\t\tPM 10: ")); Serial.println(data.pm100_standard);
Serial.println(F("Concentration Units (environmental)"));
Serial.println(F("---------------------------------------"));
Serial.print(F("PM 1.0: ")); Serial.print(data.pm10_env);
Serial.print(F("\t\tPM 2.5: ")); Serial.print(data.pm25_env);
Serial.print(F("\t\tPM 10: ")); Serial.println(data.pm100_env);
Serial.println(F("---------------------------------------"));
Serial.print(F("Particles > 0.3um / 0.1L air:")); Serial.println(data.particles_03um);
Serial.print(F("Particles > 0.5um / 0.1L air:")); Serial.println(data.particles_05um);
Serial.print(F("Particles > 1.0um / 0.1L air:")); Serial.println(data.particles_10um);
Serial.print(F("Particles > 2.5um / 0.1L air:")); Serial.println(data.particles_25um);
Serial.print(F("Particles > 5.0um / 0.1L air:")); Serial.println(data.particles_50um);
Serial.print(F("Particles > 50 um / 0.1L air:")); Serial.println(data.particles_100um);
Serial.println(F("---------------------------------------"));
pm10 = data.pm10_standard;
last_pm25 = pm25;
pm25 = data.pm25_standard;
pm100 = data.pm100_standard;
}
uint16_t getPm25Color(int v) {
if (v < 12) {
return pm25color[0];
} else if (v < 24) {
return pm25color[1];
} else if (v < 36) {
return pm25color[2];
} else if (v < 42) {
return pm25color[3];
} else if (v < 48) {
return pm25color[4];
} else if (v < 54) {
return pm25color[5];
} else if (v < 59) {
return pm25color[6];
} else if (v < 65) {
return pm25color[7];
} else if (v < 71) {
return pm25color[8];
} else {
return pm25color[9];
}
}
I took out all the tft lcd display just had serial monitoring on it. I can not get it to work. I have the RX pin on D2 I even changed it to D6 as in the image and changed it to 6 and 7 in the code. but still nothing. I have no clue what I'm missing.
Hello, I'm still having problems trying to see the PM2.5 air sensor on the esp D1Mini. I have went to adafruit site and searched for the PM2.5 sensor and tried it but I can not get it to work. This is the sketch below.
/* Test sketch for Adafruit PM2.5 sensor with UART or I2C */
#include "Adafruit_PM25AQI.h"
// If your PM2.5 is UART only, for UNO and others (without hardware serial)
// we must use software serial...
// pin #2 is IN from sensor (TX pin on sensor), leave pin #3 disconnected
// comment these two lines if using hardware serial
#include <SoftwareSerial.h>
SoftwareSerial pmSerial(4, 5);
Adafruit_PM25AQI aqi = Adafruit_PM25AQI();
void setup() {
// Wait for serial monitor to open
Serial.begin(115200);
while (!Serial) delay(10);
Serial.println("Adafruit PMSA003I Air Quality Sensor");
// Wait one second for sensor to boot up!
delay(1000);
// If using serial, initialize it and set baudrate before starting!
// Uncomment one of the following
//Serial1.begin(9600);
pmSerial.begin(9600);
// There are 3 options for connectivity!
// if (! aqi.begin_I2C()) { // connect to the sensor over I2C
//if (! aqi.begin_UART(&Serial1)) { // connect to the sensor over hardware serial
if (! aqi.begin_UART(&pmSerial)) { // connect to the sensor over software serial
Serial.println("Could not find PM 2.5 sensor!");
while (1) delay(10);
}
Serial.println("PM25 found!");
}
void loop() {
PM25_AQI_Data data;
if (! aqi.read(&data)) {
Serial.println("Could not read from AQI");
delay(500); // try again in a bit!
return;
}
Serial.println("AQI reading success");
Serial.println();
Serial.println(F("---------------------------------------"));
Serial.println(F("Concentration Units (standard)"));
Serial.println(F("---------------------------------------"));
Serial.print(F("PM 1.0: ")); Serial.print(data.pm10_standard);
Serial.print(F("\t\tPM 2.5: ")); Serial.print(data.pm25_standard);
Serial.print(F("\t\tPM 10: ")); Serial.println(data.pm100_standard);
Serial.println(F("Concentration Units (environmental)"));
Serial.println(F("---------------------------------------"));
Serial.print(F("PM 1.0: ")); Serial.print(data.pm10_env);
Serial.print(F("\t\tPM 2.5: ")); Serial.print(data.pm25_env);
Serial.print(F("\t\tPM 10: ")); Serial.println(data.pm100_env);
Serial.println(F("---------------------------------------"));
Serial.print(F("Particles > 0.3um / 0.1L air:")); Serial.println(data.particles_03um);
Serial.print(F("Particles > 0.5um / 0.1L air:")); Serial.println(data.particles_05um);
Serial.print(F("Particles > 1.0um / 0.1L air:")); Serial.println(data.particles_10um);
Serial.print(F("Particles > 2.5um / 0.1L air:")); Serial.println(data.particles_25um);
Serial.print(F("Particles > 5.0um / 0.1L air:")); Serial.println(data.particles_50um);
Serial.print(F("Particles > 10 um / 0.1L air:")); Serial.println(data.particles_100um);
Serial.println(F("---------------------------------------"));
delay(1000);
}
This is the output on serial monitor. I'm not putting a webserver on it until I can get it to run in serial monitor.
PM25 found!
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
Could not read from AQI
No matter what I do I can not get this to work. I really need help. Please someone help me?
P.s.s from everything I looked at online says the REST pin on the ikea pcb is the transmit pin for serial and I need to add it either to D4 gpio2 Or D1 GPIO5 pin. I do not honestly know I have tried everything,
I comment out the i2c one and enable the serial part.
I'm just not sure what I'm doing wrong. Here is my code.
/* Test sketch for Adafruit PM2.5 sensor with UART or I2C */
#include "Adafruit_PM25AQI.h"
// If your PM2.5 is UART only, for UNO and others (without hardware serial)
// we must use software serial...
// pin #2 is IN from sensor (TX pin on sensor), leave pin #3 disconnected
// comment these two lines if using hardware serial
#include <SoftwareSerial.h>
SoftwareSerial pmSerial(2, 3);
Adafruit_PM25AQI aqi = Adafruit_PM25AQI();
void setup() {
// Wait for serial monitor to open
Serial.begin(115200);
while (!Serial) delay(10);
Serial.println("Adafruit PMSA003I Air Quality Sensor");
// Wait one second for sensor to boot up!
delay(1000);
// If using serial, initialize it and set baudrate before starting!
// Uncomment one of the following
Serial1.begin(9600);
pmSerial.begin(9600);
// There are 3 options for connectivity!
// if (! aqi.begin_I2C()) { // connect to the sensor over I2C
// if (! aqi.begin_UART(&Serial1)) { // connect to the sensor over hardware serial
if (! aqi.begin_UART(&pmSerial)) { // connect to the sensor over software serial
Serial.println("Could not find PM 2.5 sensor!");
while (1) delay(10);
}
Serial.println("PM25 found!");
}
void loop() {
PM25_AQI_Data data;
if (! aqi.read(&data)) {
Serial.println("Could not read from AQI");
delay(500); // try again in a bit!
return;
}
Serial.println("AQI reading success");
Serial.println();
Serial.println(F("---------------------------------------"));
Serial.println(F("Concentration Units (standard)"));
Serial.println(F("---------------------------------------"));
Serial.print(F("PM 1.0: ")); Serial.print(data.pm10_standard);
Serial.print(F("\t\tPM 2.5: ")); Serial.print(data.pm25_standard);
Serial.print(F("\t\tPM 10: ")); Serial.println(data.pm100_standard);
Serial.println(F("Concentration Units (environmental)"));
Serial.println(F("---------------------------------------"));
Serial.print(F("PM 1.0: ")); Serial.print(data.pm10_env);
Serial.print(F("\t\tPM 2.5: ")); Serial.print(data.pm25_env);
Serial.print(F("\t\tPM 10: ")); Serial.println(data.pm100_env);
Serial.println(F("---------------------------------------"));
Serial.print(F("Particles > 0.3um / 0.1L air:")); Serial.println(data.particles_03um);
Serial.print(F("Particles > 0.5um / 0.1L air:")); Serial.println(data.particles_05um);
Serial.print(F("Particles > 1.0um / 0.1L air:")); Serial.println(data.particles_10um);
Serial.print(F("Particles > 2.5um / 0.1L air:")); Serial.println(data.particles_25um);
Serial.print(F("Particles > 5.0um / 0.1L air:")); Serial.println(data.particles_50um);
Serial.print(F("Particles > 10 um / 0.1L air:")); Serial.println(data.particles_100um);
Serial.println(F("---------------------------------------"));
delay(1000);
}
hey Wildbill, Just an update. My friend not around he is in the hosptial getting a pacemaker put in. So I was not able to use his scope. Also I did the most cude thing Everything I put the sensor pin connected to an analog pin on the arduino and ran a analog voltage.
The results was working. I blow into the sensor and saw voltage changes. So that is showing there is something going on. But I can not get the sensor itself to display in serial no matter what I do.