Blynk.virtualWrite causues disconnection from Local Server

Good Day,

Please can someone help me with my project.

I am running a IoT controller on one Raspberry Pi and am connected to my local Blynk Server on a second Raspberry Pi.
I am using node.js to connect to the server and everything connects and works properly until I try to send an ANALOGUE VALUE to the Blynk Application. I am reading the analogue value on from a LM35DZ and converting it using a MCP3008 (using channel 0).

I can read all values on the terminal but as soon as I add in the blynk.virtualWrite code, it bombs out.

This is my code:

var Blynk = require(‘blynk-library’); 

var AUTH = //”My Authentication Code//

var blynk = new Blynk.Blynk(AUTH, options = {	
    addr:”192.168.1.xxx”
}); 

var Mcp3008 = require('mcp3008.js');
var adc = new Mcp3008();

var v1 = new blynk.VirtualPin(1);

var temp = function (value) {

            var volts = (value * 3.3) / 1023;
            var temperature = volts / (10/1000);

           console.log("Raw Value = ", value);                            // Working
           console.log("Volts = ", volts.toFixed(3));                     // Working
           console.log("temperature = ", temp.toFixed(1));          // Working
           blynk.virtualWrite(1, temperature.toFixed(1));             // Not Working
};
adc.read(0, temp);
adc.poll(0, 2000 temp);

When adding the blynk.virtualWrite line, i cannot connect to the local server, but when I comment it out, I can.

Please Help!!

Thanks

Adding this here from the other thread you started.
Please don’t create additional threads for the same problem. I don’t think there are any restrictions on new users editing their threads so just edit any errors you make. Blynkers with problems need to provide as much information as possible and in due course we might put together a 200 page form to complete prior to offering assistance :grin:

LOOOOOOK:::::

blynk.virtualWrite(1, temperature.toFIxed(1));

is not

blynk.virtualWrite(1, temperature.toFixed(1));

fin?

Presumably with the ADC this statement is not factually correct, right?

Sorry, I manually typed the code, the syntax is correct on the actual code.

Sorry bout that…

Yes that is true

Are you able to edit your original post with the correct syntax?
I don’t really have a clue what the correct syntax is for java.

Please show the precise syntax for the working write’s to Terminal.

I have edited the original post, thanks so much for the quick responses!!

@jarryd10 thanks for the edit. Presumably volts.toFised(3) is actually volts.toFixed(3) ?

Not all widgets / functions use the same datatypes.

If you look at the virtualWrite syntax in the comprehensive docs at http://docs.blynk.cc/#blynk-firmware-virtual-pins-control-blynkvirtualwritevpin-value does that point you in the right direction (as inferred by @Dave1829’s ‘LOOOOOOK:::::’ post?

Are you an experienced java coder?

I am a beginner so a lot of it doesn’t make sense,

This is just a small project for home use, so I’s learning as I go.

I will have a look at the documentation you’ve prescribed and will take a look at the code again tonight when I get home from work.

Thanks for the help, I will provide updates asap.

1 Like

you need to show us the code that is not working, not what you remember it being…

1 Like