Burning file to a chosen target with one programmer

Hi everyone.

I'm 21, and i'm at the end of my master's degree in engineering. I'm new here, because I'm specialising in metal works lol. :upside_down_face:
I never was that good in coding but for the sake of a project I jumped into it.

So, I have a project, where I'm supposed to make resistivity sensors for steel in concrete, so we can know when they rust. That's the overall aim of the project.
Before, they had to plug a wire into each sensor. Now we want to have to plug it once, and then choose which sensor we are talking to. Sweet.

So what I understand (Arduinowise) is that I have to burn a bootloader on many target boards, in my case a Nano, from the same programmer, Uno.
Then using a breadboard, I'll connect many targets.
So the external device will ask my Uno to ask the Nano X to give its values.

Using Avrdudess I've flashed the blink code (converted in .hex with IDE) to my programmer and my target answers successfully. So I did the same for my measurement code, but I don't know how to choose 1 target among others.. That's were I'm stuck.

Is it even possible to do what I'm talking about ? I have a lot of codes from older students and me so if you want to see something let me know, it's the overall process that I'm not sure about. I'm mixing everything, optiboot, avr...

Thanks for your time.
Matthieu

How many sensors are there and what type are they ?

Hi,
Thanks. Here are the different sensors.
2 resistivity sensors
3 temperature and humidity sensors
4 PT100 sensors
3 chloride sensors
3 potential sensors

The link between the nano and part of the sensors has already been made.

What type of interface do each of the sensors have ?
SPI ?
I2C ?
Serial ?
Analogue ?
Something else ?

They have I2C interface

Hi,
If you are using Nano, you don't have to worry about loading bootloaders, the bootloader is already loaded, that is why you can program them.

How many Nano do you have, one per sensor?
Are the sensors grouped so you can use one Nano for a number of them?

Did you breadboard the network or just each Nano to see if it was working with its sensor?

Are you using the Arduino IDE to program?

Can you please post a block diagram of how you envision them being connected together?

Tom.. :smiley: :+1: :coffee: :australia:

It sounds like we are thinking along the same lines

Hey Tom, thanks for your reply.

Yes, I have one Nano per group of sensor. I didn't breadboard the network as I couldn't figure out how to choose which sensor to read from.
I'm using the IDE to program yes.

I can show you this :

Hope it helps.
Thanks again.

Edit; that's the resistivity sensor connected to the nano. I suppose I'll put nanos just like that : (see next post)

Hi,
How far apart will the Nanos be?

Tom... :smiley: :+1: :coffee: :australia:

Actually we were also thinking about LIN bus for inter-microcontroller communication. I think I2C isn't meant for long distances.

Hi,
I2C is limited by the distance, originally designed for comms on a PCB.

CanBus is another possibility, there are Canbus breakout boards and Arduino libraries that would help.

Tom.. :smiley: :+1: :coffee: :australia:

Hey, thanks Tom, I didn't know Canbus, i'll search more about it.

But I still don't understand the "chosing the right nano" part.. I don't know if I have to use the IDE or use .hex programs with avr..

Hey,
In order to understand more the basics of communication, I am trying I2C wich seems to be the simplest harware-wise.

But I2C scanner Taken from Arduino.com is only recognizing one Nano among another Nano and a méga. I have tried with another Uno. Master is an Uno.
Weird thing is that alone my other boards are not found on the I2C bus, only this one Nano..
I have put pull up resistor and it us the same with or without..

I tried using sca and scl pin A4 and A5 aswell as the 2 pins above D13, same for méga
I have found a post and i checked the scl and sca ports, they both seems to work (give 1 and 0 at the good time)

Someone has an Idea ? I'll put a picture
Thanks

Hi,
Have you given each of the Nanos a different address?

If you check each Nano on its own, does the I2C scanner detect them?

Tom... :smiley: :+1: :coffee: :australia:

Thanks Tom.

I didn't know i could give each Nano a different adress. How do I do that ?

Yes, only one of my boards (2 megas, 2 unos and 2 nanos) is recognized alone. Others aren't even without any breadbord..

Hi,
Can you post the master code and the slave code please?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

I have only used the code I2C scanner available in the exemples, I wanted to know each adresses so I could try to choose with wich one i'll speak.

#include <Wire.h>

void setup()
{
  Wire.begin();

  Serial.begin(9600);
}

void loop()
{
  int error;
  int address;
  int devices = 0;

  Serial.println("Devices found:");

  for(address = 1; address < 127; address++ ) 
  {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
      devices++;
    }
    
    else if (error==4) 
    {
      Serial.print("Unknown error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  
  if (devices == 0)
    Serial.println("No I2C devices found");

  delay(5000);           
}

Hi,
You need to have I2C based code on the slave at least.
Google;

arduino I2C master and slave

This is a good start;

Tom... :smiley: :+1: :coffee: :australia:

Thanks,

I saw that. But I2C scanner should recognize the boards ?