I am trying to simplify an air quality sensor set up for a schools project by moving it from an Uno board to a WeMos D1 R1 (less wires, easier power, built in wifi).
I'm using the Honeywell HPMA115S0 sensor, and the library at GitHub - felixgalindo/HPMA115S0: Arduino Library for Honeywell's Particle Sensor (HPMA115S0-XXX)
It compiles fine on the Uno, but changing across to the ESP8266 WeMos, I am getting multiple errors all in the format;
\HPMA115S0-master\src\hpma115S0.cpp: In member function 'void HPMA115S0::DisableAutoSend()':
\HPMA115S0-master\src\hpma115S0.cpp:171:17: error: invalid conversion from 'const char*' to 'unsigned char*' [-fpermissive]
SendCmd(cmd, 4);
I am assuming this is due to some variation in the way the code needs compiling for WeMos board, and looking online, have seen discussions about declared constants (but can't see any of this happening in the .h file)
Is there a simple tweak to allow this library to work on the WeMos board?
Thanks
/**
* @file example.ino
* @author Felix Galindo
* @date June 2017
* @brief Example using HPMA115S0 sensor library on a Feather 32u4
* @license MIT
*/
#include <hpma115S0.h>
#include <SoftwareSerial.h>
//Create an instance of software serial
SoftwareSerial hpmaSerial(10, 11); // Feather TX, Feather RX
//Create an instance of the hpma115S0 library
HPMA115S0 hpma115S0(hpmaSerial);
void setup() {
Serial.begin(57600);
hpmaSerial.begin(9600);
delay(5000);
Serial.println("Starting...");
hpma115S0.Init();
hpma115S0.StartParticleMeasurement();
}
void loop() {
unsigned int pm2_5, pm10;
if (hpma115S0.ReadParticleMeasurement(&pm2_5, &pm10)) {
Serial.println("PM 2.5: " + String(pm2_5) + " ug/m3" );
Serial.println("PM 10: " + String(pm10) + " ug/m3" );
}
delay(1000);
}
HPMA115S0.h (2.91 KB)
hpma115S0.cpp (5.08 KB)