Agents gone fishing?

Wrote my first agent yesterday, worked really fine. Today my agent just won’t get triggered. The imp is working and doing its agent.set() rap but no response on the agent side. Anything that can be done on user side (mine) to get things working again?

Can you post your agent code or, if it’s confidential, send it to

What’s agent.set()?
Do you mean agent.send()?

Sorry about the typo, meant agent.send(). What’s happening now is that my agent seem to run now, but I can’t update it through the IDE - none of my changes are deployed unless I deploy some other code to the imp and then redeploy what I’m working on. I’ve restarted browser, re-logged in etc but to no avail…

Here’s my simple agent code for testing. The agent responds to http requests as it should.

`function reportsuccess(response)
server.log("Result: " + response.statuscode);

function sendtocosm(value) {
server.log("Value: " + value);

local req = http.put("",
    { "Content-Type": "text/csv", "X-ApiKey": "mySecretApiKey" },
    "" + value);


function mywebserver(request,res)
if (request.body == “0”){
res.send(200, “OK”);
} else {
res.send(701, “Meh”);


device.on(“humidity”, sendtocosm);`

Just wondering - is there device code at all? Can you add logging to your agent so you can tell when it’s been restarted?

Sure, there is device code. And it DOES work now, but new agent code is only deployed when I assign other code to the imp and then re-assign with the code I’m working on. Should also mention that the Deploy button in IDE is grayed out, if that means anything.

I have logging in my agent code but as far as I can see it is never restarted after I change the code.

Just some more info. I’ve tried running Chrome as well, instead of Safari, but it’s the same result. And I tried making a new Model with the same code. Same behavior, agent never restarts after code changes, I must deploy another model to the imp and then go back again to get the agent restart with new code. Makes it very tedious to develop… :slight_smile:

Aaand, here is the imp code if that helps:

`// Analog in, reading the soil probe. Will be between 0 - 3V.
// Power control of the soil probe. Set 1 to enable.

function doMeasure() {
// Power up the soil probe
// Power-on-to-stable is 400 ms according to specs

// Read and convert to voltage

[boring code snipped away]

// Do we have previously saved value? Only send if there's a change
if (("nv" in getroottable()) && ("vwc" in nv)) {
    if (vwc != nv.vwc) {
        nv.vwc = vwc;
        agent.send("humidity", vwc); 
} else {
    nv <- {vwc = 0};


imp.configure(“Soil Humidity Logger”, [], []);

// Enter deep sleep, wake every minute
imp.onidle(function() {
server.sleepfor(60 - (time() % 60));

We’ve worked out that the play button won’t restart the agent if the associated imp is asleep; maybe comment out your onidle whilst debugging this for the meantime?

One thing: if you’re trying to power a probe directly from a GPIO:

a) The probe shouldn’t be taking more than 4mA
b) You want to configure it as DIGITAL_OUT, not DIGITAL_OUT_OD_PULLUP as that mode will be supplying the probe through a huge resistor.

…of course, you may already have a FET in there for power control, but thought I’d mention this anyway :slight_smile:

I just woke up to this good news: no sleep while debugging. :slight_smile: Thanks for finding this. It’s a good enough workaround for the moment.

And I do have a FET driving my probe - I’ve blown up too many things in my career already. :))