Remote temp sensor project

I am a complete newbie at this and have been searching everywhere I can find to figure out my problem. I will describe the system and symptoms and maybe one of the smart people here can help me get this thing going.

I have 2 Mega 2560s connected via 1000 feet of fiber through serial modems. One transmits temp data from a TMP36 sensor and the other receives it and prints it to the serial monitor. The transmitter end will be buried in an armored container to read temperature underground from about 1000 feet away. The system will not have battery power to keep the system alive, due to design criteria, or be running until I need a temp reading. At that point I will attach the 12VDC voltage source to the transmitter’s barrel jack via the composite fiber cable (fiber and copper in one jacket) and a USB cable to the receiver for reading the temperature on my laptop.

The obstacle for me to overcome is I need the transmitter to power on and start sending temp data when the 12VDC power is applied. No USB or reset are possible. When both are powered via USB, the system works perfectly. The receiver is the indicator I use to judge whether the sketch in the transmitter is running or not.

The transmitter is outputting serial data to the modem via pins 0 and 1. The temp sensor is attached to pin A0.

This is the transmitter code that I am using (I commented out the voltage and degrees C print lines since I don’t need that data):

//TMP36 Pin Variables
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
                        //the resolution is 10 mV / degree centigrade with a
                        //500 mV offset to allow for negative temperatures
 
/*
 * setup() - this function runs once when you turn your Arduino on
 * We initialize the serial connection with the computer
 */
void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
 Serial.println ("Hello");//Start the serial connection with the computer
                       //to view the result open the serial monitor 
}
 
void loop()    
{   
 // run over and over again
 //getting the voltage reading from the temperature sensor
 int reading = analogRead(sensorPin);  
 
 // converting that reading to voltage, for 3.3v arduino use 3.3
 float voltage = reading * 5.0;
 voltage /= 1024.0; 
 
 // print out the voltage
 //Serial.print(voltage); 
 //Serial.println(" volts");
 
 // now print out the temperature
 float temperatureC = (voltage - 0.5) * 100 ; 
 
 //converting from 10 mv per degree wit 500 mV offset
 //to degrees ((voltage - 500mV) times 100)
 //Serial.print(temperatureC); 
 //Serial.println(" degrees C");
 
 // now convert to Fahrenheit
 int temperatureF = (temperatureC * 9.0 / 5.0) + 32.0; 
 Serial.println(temperatureF);
 Serial1.println(temperatureF); 
 //Serial.println(" degrees F");

 
 
 delay(1000);                                     //waiting a second
}]

And this is the receiver code:

int templog = 0;

void setup() {
  //start serial comms
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial.println("set-up good");
}

void loop() {
  int i=0;
  
  if (Serial1.available()) {
    //allows all serial sent to be received together
    delay(500);
     
   while(Serial1.available() && i<5) {
      templog = Serial1.parseInt();
     i = i + 1;
    }
  }
//templog = Serial1.read();

 if(i>0) {
     delay(500);
  Serial.println(templog);  
  }
 
}

I would really appreciate any insights or input on this. It is a work project and I have been making my eyes bleed fumbling around on the net trying to puzzle this out. :slight_smile:

Warren

What is a TM36? I can't find that at Digikey to read its datasheet.
https://www.digikey.com/products/en?keywords=TM36

Sorry about that. It is a TMP 36. I will edit the original post. Thanks.

Warren

Warren,
Not to confuse me as smart guy, but I also have two arduinos communicating via serial comms. They communicate perfectly - no matter what order of the power up. I used this as a comm guide.

For the smart guys in the room to help, it may be appropriate to post both the transmit Mega’s code (primarily the serial write) and the receiver Mega’s code (primarily the serial read); it appears to be a sync issue.

Also, as a side note, the Mega performs a reset when the Serial Monitor is initiated - at least on my machine.

Also helpful -when replying to the thread, use the </> to neatly consolidate your code for viewing.

Hope this helps… a little.

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

What is the problem you’re encountering? Or are you just looking for general comments on the project?

Sorry about the rookie mistake. I have edited the original to save confusion.

The transmitter code was found on the web and the receiver code was written by a colleague.

JMeller:
Warren,
Not to confuse me as smart guy, but I also have two arduinos communicating via serial comms. They communicate perfectly - no matter what order of the power up. I used this as a comm guide.

For the smart guys in the room to help, it may be appropriate to post both the transmit Mega’s code (primarily the serial write) and the receiver Mega’s code (primarily the serial read); it appears to be a sync issue.

Also, as a side note, the Mega performs a reset when the Serial Monitor is initiated - at least on my machine.

Also helpful -when replying to the thread, use the </> to neatly consolidate your code for viewing.

Hope this helps… a little.

Thanks. I’ll do it right next time. :slight_smile:

pert:
Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

What is the problem you’re encountering? Or are you just looking for general comments on the project?

I have fixed that mistake. Thanks for the information. The issue is described in the original post. Not looking for general commentary, just a solution.

ni5l:
When both are powered via USB, the system works perfectly.

OK, so we know it works powered via USB.

ni5l:
The obstacle for me to overcome is I need the transmitter to power on and start sending temp data when the 12VDC power is applied.

I guess what you're saying here is it's not working correctly when powered via 12 VDC? Please provide more details on exactly what the problem is.

Yes, that is precisely the problem.

I cannot get the transmitter to start transmitting its temp data with only the 12VDC power applied. The board powers up but the sketch fails to run. This is verified by the lack of blinking TX light and no temp data out of the receiver.

Warren

Not knowing your schematic, I am only guessing; voltage input jack has automatic switching - see reply #1.

JMeller:
Not knowing your schematic, I am only guessing; voltage input jack has automatic switching - see reply #1.

The board is just a stock Mega 2560 and the only connections are the TMP 36 (a TO-92 cased sensor) plugged into 5V, GND and A0.

I apologize for the confusion; it appears to be related to the 12V power supply interface. According to the link in the previously post, most problems were solved by plugging the alternate source, in this case the 12V, directly into the radial input jack. I didn’t know if your 12V was interfaced to a 5V regulator and then passed to the Vin (NOT 5V pin) and Gnd pin to power the Mega. If that is the case, see previous link. Otherwise, a series of troubleshooting steps would need to be performed.

Moderator please delete this thread.