How can i get this to work again, dont understand the agent setup?

Hi, this was working but not anymore, because of the agent setup…

can somebody help getting this to work again ? thanks in advance
the output data should be send to a local server at my office.

`// April with a 10k, 1% from 3V3 to pin9 and 10k EPCOS - B57891M0103K000 Farnell NTC Thermistor from pin9 to pin8
// pin8 TEMP_READ_EN_L - drive low to enable temp reading (great for batteries!)
// pin9 ANALOG NTC value

// turn on WiFi power save to reduce power consumption when awake
imp.setpowersave(true);

local my_id = “00000001”

// Output structure for sending temperature to server
local tempOut = OutputPort(“Temperature ©”, “number”);
local tempOutStr = OutputPort(“Temperature ©”, “string”);
local battOut = OutputPort(“Battery Voltage”, “number”);
local output = OutputPort(“my_id, Temp1, Temp2, Temp3, Volts, SupplyVolts”, “table”);

// Configure on planner and register with imp server
//imp.configure(“April NTC Thermometer”, [], [tempOut, tempOutStr, battOut]);
imp.configure(“Buffels NTC Thermometer”, [], [output]);
//imp.configure(“UartCrossAir”, [dTable], output)

// Configure Pins
// pin 8 is driven high to turn off temp monitor (saves power) or low to read
hardware.pin8.configure(DIGITAL_OUT);
hardware.pin8.write(1);
// pin 9 is the middle of the voltage divider formed by the NTC - read the analog voltage to determine temperature
hardware.pin9.configure(ANALOG_IN);

// pin 9 is the middle of the voltage diverder formed by a 1.2k and 2.7k restistor to determine voltage at power supply
hardware.pin5.configure(ANALOG_IN);

// all calculations are done in Kelvin
// these are constants for this particular thermistor; if using a different one,
// check your datasheet
const b_therm = 3950;
const t0_therm = 298.15;

// to read the battery voltage reliably, we take 10 readings and average them
local v_high = 0;
for(local i = 0; i < 10; i++){
imp.sleep(0.01);
v_high += hardware.voltage();
}
v_high = v_high / 10.0;

// turn on the thermistor network
hardware.pin8.write(0);
// gather several ADC readings and average them (just takes out some noise)
local val = 0;
for (local i = 0; i < 10; i++) {
imp.sleep(0.01);
val += hardware.pin9.read();
}
val = val/10;
// turn the thermistor network back off
hardware.pin8.write(1);

local val2 = 0;
for (local i = 0; i < 10; i++) {
imp.sleep(0.01);
val2 += hardware.pin5.read();
}
val2 = val2/10;
//val2 = val2/65535.0;
local cV = 0;
cV = 3.3 * val2 / 65535;
cV = cV * 3.2 // Voltage divider

// scale the ADC reading to a voltage by dividing by the full-scale value and multiplying by the supply voltage
local v_therm = v_high * val / 65535.0;
// calculate the resistance of the thermistor at the current temperature
local r_therm = 10000.0 / ( (v_high / v_therm) - 1);
local ln_therm = math.log(10000.0 / r_therm);

local t_therm = (t0_therm * b_therm) / (b_therm - t0_therm * ln_therm) - 273.15;

// convert to fahrenheit for the less-scientific among us
//local f = (t_therm) * 9.0 / 5.0 + 32.0;
local f = (t_therm) ;
// format into a string for the string output port
local f_str = format("%.01f", f)
server.log("Current temp is "+f_str);

// emit values to our output ports
tempOut.set(f_str);
//tempOutStr.set(f_str+" C");

// update the current battery voltage with a nicely-formatted string of the most recently-calculated value
//local batt_str = format("%.02f V",v_high)
local batt_str = format("%.02f",v_high)
battOut.set(batt_str);
server.log("Battery Voltage is "+batt_str);

server.log("Power Supply Voltage is "+cV);

local dTable = {
“my_id” : my_id,
“temp1” : f,
“temp2” : “10.00”,
“temp3” : “5.00”,
“volt” : v_high,
“svolt” : cV
}

output.set(dTable);

server.log(format(“Running on %.2f V at %.1f Celsius”, v_high, f));

//Sleep for 15 minutes and 1 second, minus the time past the 0:15
//so we wake up near each 15 minute mark (prevents drifting on slow DHCP)
//imp.wakeup(3, function() { server.sleepfor(1 + 1560 - (time() % (1560))); });
// 1 minute
//imp.wakeup(3, function() { server.sleepfor(1 + 160 - (time() % (160))); });

// 5 minute
imp.wakeup(3, function() { server.sleepfor(1 + 560 - (time() % (560))); });

// full firmware is reloaded and run from the top on each wake cycle, so no need to construct a loop`

Edit: wrapped code in a < code > </ code > tag

please wrap your code in codetags:

  1. click edit
  2. select program code
  3. click the “C” tab, just above the editing window
  4. Push “Post Comment”
  5. refresh page

Tom updated your Tempbug code recently. According to Instructables this is the current code…