error: invalid types 'float[int]' for array

according to this site:

I am insisting in use Serial.write

And I have this error:

What site? What error? Image?

Please read the guidelines for posting on this Forum in the posts by Nick Gammon at the top of the page. You have not given enough information to even guess what your problem is, let alone a solution.

add .ino file

sketch_ACS712_status_da_corrente.ino (2.13 KB)

Why do you insist on using .write instead of .print?

What happens when you make the change?

HazardsMind: Why do you insist on using .write instead of .print?

What happens when you make the change?

Becase I need read (currentValue) in raspberry pi (serial communication) with this script:

import serial port = "/dev/ttyACM0" serialFromArduino = serial.Serial(port,9600) serialFromArduino.flushInput() while True: if (serialFromArduino.inWaiting() > 0): input = serialFromArduino.read(1) print(ord(input))

currentValue is declared a float at the top of the sketch, it is not an array!

pYro_65: currentValue is declared a float at the top of the sketch, it is not an array!

Please pYro_65,

What I need do correct tha ??

currentValue is a single float variable YET you are treating it as if it's an array of variables.

neuberfran:
Please pYro_65,

What I need do correct tha ??

If you want to write out the 4 bytes that make up the float you can do this:

Serial.write( (char*)&currentValue, 4 );

pYro_65: If you want to write out the 4 bytes that make up the float you can do this:

Serial.write( (char*)¤tValue, 4 );

https://onedrive.live.com/?cid=FFD2AD7897D0C5DE&id=FFD2AD7897D0C5DE%212650&v=3

neuberfran: https://onedrive.live.com/?cid=FFD2AD7897D0C5DE&id=FFD2AD7897D0C5DE%212650&v=3

more errors

neuberfran: more errors

This item might not exist or is no longer available

This item might have been deleted, expired or you might not have permission to view it. Contact the owner of this item for more information.

Post the errors and related code here. You link doesn't work as live.com just tries to access the file in my own onedrive which doesn't exist.

here ondrive file

Serial.write ((char*)¤tValue, 4);

The compiler is telling you exactly what's wrong. Or am I missing something?

AWOL:
Serial.write ((char*)&currentValue, 4);
The compiler is telling you exactly what’s wrong.
Or am I missing something?

Nah, its a version incompatibility, I’m using 1.5.7, and the OP is using 1.0.5.

It appears this was added to 1.5.x
https://github.com/arduino/Arduino/commit/250386802f3674311acd1b1481426c3e00aeebdd

In previous versions, you can do what the new function does manually.

Serial.write((const uint8_t *)buffer, size);

errors persists

help please guys

I need do measure voltage in the arduino (serial connect with raspberry pi → running python script)

In the python script I send to mqtt topic

Document1.c (1.15 KB)

neuberfran: errors persists

That is because you copied my example directly, which was a generalized example in no way specific to your code (most of the line is copied from the link I provided). You need to replace 'buffer' and 'size' with the appropriate variables/values in your code.