Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By kolban
#25049 Hi burkmurrray,
Thanks for the kind words ... thankfully I have a glass half full disposition most of the time and when something doesn't work that is a new opportunity for me to learn something. So when my I2C solution didn't work, it was an opportunity for me to practice debugging techniques. I had recently bought an 8 channel logic analyzer but hadn't had a great purpose to use it ... so this proved a great reason. Of course, when I failed to see a CLK signal through my new logic analyzer, I wasn't yet sure if I was using THAT new tool correctly ... so there were a lot of permutations to try.

As for this being the biggest problem of the week ... not even close ... but that's ok ... there are countless mysteries associated with our ESP8266 hobby/study ... some unveil themselves quickly, some are as opaque as ever. For example, today I was trying to use the Arduino Eclipse project to build Arduino ESP apps and found that the Arduino Eclipse project doesn't know what to do with ".S" files which I believe are assembler source ... so now I have a new major puzzle on how to get the Arduino Eclipse environment building the Arduino ESP.

We are going to need to think up some new language soon ... as now we have IDEs:

o Command line
o Eclipse
o Arduino

and libraries:
o Espressif SDK
o Arduino ESP

and mappings from some to some of the IDEs to the libraries ...

o Command line Espressif SDK
o Eclipse Espressif SDK
o Arduino IDE with Arduino libraries
o Command line with Arduino libraries
o Eclipse with Ardunio libraries

And I fear this is just the beginning :-)
User avatar
By martinayotte
#25091
kolban wrote:For example, today I was trying to use the Arduino Eclipse project to build Arduino ESP apps and found that the Arduino Eclipse project doesn't know what to do with ".S" files which I believe are assembler source ...


Are you compiling under Linux ?
Just be aware of case-sensitive. I got such problem few weeks ago with a project (I don't remember which one, maybe not even an ESP related, maybe STM32 or mBed) where the Makefile didn't compile assembly files, I had simply to rename those files in lower case *.s
User avatar
By fish
#29224 There is a source code available (viewtopic.php?f=29&t=2865) that (almost) works with the arduino (1.6.5) library 'wire.h' and the MLX90614. However, there's one mistake in it. Just change 'wire.pins(4,5)' into wire.begin(4,5) and everything will be fine! If you don't know the slave address (default = 0x5A) of your (single!) IR-thermometer just use the universal address (0x00).

The code that works:

//SDA --- GPIO4
//SCL --- GPIO5

#include <Wire.h>

#define MLX90614_TA 0x06
#define MLX90614_TOBJ1 0x07

void setup() {
// put your setup code here, to run once:

//Wire.pins(4,5);
Wire.begin(4,5); //SDA=4, SCL=5
Wire.setClock(100000);
Serial.begin(9600);
}


uint16_t read16(uint8_t addr, uint8_t i2c_addr){
uint16_t ret;

Wire.beginTransmission(i2c_addr); // start transmission to device
Wire.write(addr); // sends register address to read from
Wire.endTransmission(false); // end transmission

Wire.requestFrom(i2c_addr, (uint8_t)3);// send data n-bytes read
ret = Wire.read(); // receive DATA
ret |= Wire.read() << 8; // receive DATA

uint8_t pec = Wire.read();

return ret;
}


float readTemp(uint8_t reg, uint8_t i2c_addr) {
float temp;

temp = read16(reg, i2c_addr);
temp *= .02;
temp -= 273.15;
return temp;

}

double readObjectTempC(uint8_t i2c_addr) {
return readTemp(MLX90614_TOBJ1, i2c_addr);
}


double readAmbientTempC(uint8_t i2c_addr) {
return readTemp(MLX90614_TA, i2c_addr);
}

void loop() {
// put your main code here, to run repeatedly:
Serial.print("Ambient = "); Serial.print(readAmbientTempC(0x5A));
Serial.print("*C\tObject = "); Serial.print(readObjectTempC(0x5A)); Serial.println("*C");

Serial.println();
delay(2000);
}
User avatar
By jkj@myrun.dk
#57281 Heads up Fish

Thanks I had missed out the endTransmission(false) - have seen lots of examples with out.
Works perfect now
Regards Jørgen

#elif ARDUINO_ARCH_ESP8266
Wire.beginTransmission(setI2CAddr);
Wire.write(addr);
Wire.endTransmission(false);
Wire.requestFrom(setI2CAddr,(uint8_t)1,true);
res = Wire.read();
//Wire.endTransmission();
#endif