@ericvdb
Hi, yeah sorry for that. I only realised that when I took a closer look at your sketch because it gave me the check wires message..
Thanks a lot, I've now put the radio on a seperate pin too powering it down and let the radio reinitialize by using gw.begin(); in the void loop section.
This is the final code now and it is working well!
#include <SPI.h>
#include <MySensor.h>
#define CHILD_ID_LIGHT 0
#define LIGHT_SENSOR_ANALOG_PIN 1
#define MIN 300 // Liquid
#define MAX 700 // Air
int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
int power =4;
int radio =5;
MySensor gw;
MyMessage msg(CHILD_ID_LIGHT, V_HUM);
int lastLightLevel;
void setup(){
pinMode(power, OUTPUT);
digitalWrite(power, HIGH);
pinMode(radio, OUTPUT);
digitalWrite(radio, HIGH);
delay (5000);
Serial.begin(9600);
gw.begin();
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Mobile Sensor 1", "Kruiden");
// Register all sensors to gateway (they will be created as child devices)
gw.present(CHILD_ID_LIGHT, S_HUM);
digitalWrite(power, LOW);
}
void loop(){
// Turn sensor On
digitalWrite(power, HIGH);
// Turn Radio on
digitalWrite(radio, HIGH);
// read the value from the sensor:
delay (5000);
gw.begin();
sensorValue = analogRead(sensorPin);
int lastsensorValue = sensorValue;
Serial.println(sensorValue);
int sendValue = map(sensorValue, 0, 842, 0, 100);
gw.send( msg.set( sendValue ) );
// Turn sensor Off
digitalWrite(power, LOW);
// Turn radio off
digitalWrite(radio, LOW);
gw.sleep(3600000);
}```