Hi just loading the arduino code for the first time and noticed it doesn’t compile. Is there something i’m missing here?
I had this exact same problem when I started, I think getting the Adafruit ads1x15 library for the A/D converter fixed the issue but its been awhile.
Until I figured that out I just used the included flash utility to flash the nano.
Looks like you have selected an esp board instead of the Arduino Nano
Under tools on the menu, select the correct board
This can work for the ads without a library.
// based on https://github.com/RalphBacon/ADS1115-ADC/blob/master/ADS1115_ADC_16_bit_SingleEnded.ino
uint16_t ReadAds1115(byte NextPinNumber = 0, int I2Caddress = 0x48)
{
// read current value
Wire.beginTransmission(I2Caddress);
Wire.write(0b00000000); //Point to Conversion register
Wire.endTransmission();
Wire.requestFrom(I2Caddress, 2);
uint16_t convertedValue = (Wire.read() << 8 | Wire.read());
// do next conversion
Wire.beginTransmission(I2Caddress);
Wire.write(0b00000001); // Point to Config Register
// Write the MSB + LSB of Config Register
// MSB: Bits 15:8
// Bit 15 0=No effect, 1=Begin Single Conversion (in power down mode)
// Bits 14:12 How to configure A0 to A3 (comparator or single ended)
// Bits 11:9 Programmable Gain 000=6.144v 001=4.096v 010=2.048v .... 111=0.256v
// Bits 8 0=Continuous conversion mode, 1=Power down single shot
switch (NextPinNumber)
{
// single ended
case 1:
Wire.write(0b01010000);
break;
case 2:
Wire.write(0b01100000);
break;
case 3:
Wire.write(0b01110000);
break;
default:
Wire.write(0b01000000);
break;
}
// LSB: Bits 7:0
// Bits 7:5 Data Rate (Samples per second) 000=8, 001=16, 010=32, 011=64,
// 100=128, 101=250, 110=475, 111=860
// Bit 4 Comparator Mode 0=Traditional, 1=Window
// Bit 3 Comparator Polarity 0=low, 1=high
// Bit 2 Latching 0=No, 1=Yes
// Bits 1:0 Comparator # before Alert pin goes high
// 00=1, 01=2, 10=4, 11=Disable this feature
Wire.write(0b00000011);
Wire.endTransmission();
return convertedValue;
}
As Brian says, ensure you have the right board selected.
Another tip is to just upload a blank default sketch first, if that doesn’t upload then you know the problem isn’t with the sketch.
Brian, you were correct I had worked with a different controller and had not reset it the arduino IDE to a nano. As soon as I did this everything compiled great, I feel foolish for not seeing this before and reaching out to you guys. Thanks to everyone for your help.
I got the TCCR1B group of errors cleared up without changing code after adding the ads library.
Also using the Arduino web app IDE worked every time as all libraries are active, just the standalone ide had the issue.
But I see this was wrong board.
Oh shoot - you can’t believe how often i have done this !!
Never pause to ask. Sometimes you just need a second set of eyes to save a bunch of frustration.