float conversion

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
petergebruers
Posts: 248
Joined: 26 Jul 2015 17:29

Re: float conversion

Post by petergebruers »

I have connected a DS18B20 and an OLED display, so now I can fully run and test your sketch.

While doing so, I discovered that the DS18B20 example has the 4K7 pull-up and the VCC of the sensor connected to 5.0 V. This injects a small current into the Z-Wave SoC because it is a 3.3V chip (and due to the voltage drop across a diode it is actually more like 3.0 V) and you should not pull an input above that supply of the SoC + 0.3 V. It is not a lot of current, but I think it is technically incorrect. I have connected the resistor and the sensor to 3V3 output of the Z-Uno instead, the DS18B20 is happy with that!

User avatar
PoltoS
Posts: 5682
Joined: 26 Jan 2011 19:36

Re: float conversion

Post by PoltoS »

coco82 wrote:
30 Sep 2017 18:09
- the array declaration with default values don't work:
uint8_t row_offsets[4] = {0x00, 0x40, 0x14, 0x54); // default values are ignored
Are you sure about the ending brace? ) -> }. Is it local or global definition?
coco82 wrote:
30 Sep 2017 18:09
- in the header, the binary constants (En, Rs, Rw) make a compilator error. I converse it to hex constant.
Those are constants that should be defined in your lib, they are not well known.

petergebruers
Posts: 248
Joined: 26 Jul 2015 17:29

Re: float conversion

Post by petergebruers »

PoltoS, your previous post suddenly made me realize that I am confused again! I installed coco82's sketch and I did not use any other library... It just works, including the OLED display! It has been running for 12h now and it is still display temperature and the green LED is still blinking.

Let me go back to one of your previous posts:
coco82 wrote:
30 Sep 2017 18:09
First, I took the Arduino LiquidCrystal_I2C library, and I made few changes to make it works with Z-Uno. It's small changes, and I don't remember all I did, but :

- the array declaration with default values don't work:
uint8_t row_offsets[4] = {0x00, 0x40, 0x14, 0x54); // default values are ignored
- in the header, the binary constants (En, Rs, Rw) make a compilator error. I converse it to hex constant.

In my program, I receive a temperature from a DS18B20 sensor, and I try to print it on a I2C LCD print. Sometimes, it works once or twice but after it starts to print special symbols et fills the screen. It seems that the Serial always works.

Maybe, it comes from the library... I can send you the files if you want.
If I google that, I get this library:

https://github.com/fdebrabander/Arduino ... 2C-library

And I see:

#define En B00000100 // Enable bit
#define Rw B00000010 // Read/Write bit
#define Rs B00000001 // Register select bit

The SDCC compiler used in the Z-Uno framewark does not like that, it wants a numerical constant to begin with 0 (zero), like this:

#define En 0B00000100 // Enable bit
#define Rw 0B00000010 // Read/Write bit
#define Rs 0B00000001 // Register select bit

Anyway, I would not try to fix that "Arduino-LiquidCrystal-I2C-library" but remove it from your sketch and use the Z-Uno built-in oled library.

Do I makes sense? Can you try this?

petergebruers
Posts: 248
Joined: 26 Jul 2015 17:29

Re: float conversion

Post by petergebruers »

I have some good news... or should I say "bad news"! The green LED stopped blinking!

I have now made one change and I have to admit that this is a long shot. But personally I think it makes the display a bit nicer too.

Instead of:

Code: Select all

oled.print(temperature);
I now do:

Code: Select all

oled.print(temperature, 1);
For debugging, i decreased the delay from 30 to 3 seconds and I also report at each run of the loop. If we are lucky, this speeds up the test. Let's wait and see.

I think this issue has another cause, but at the moment I am out of ideas.

coco82
Posts: 9
Joined: 25 Sep 2017 22:25

Re: float conversion

Post by coco82 »

First, thanks to spend times on my problem, even if I found a different way to move forward.

For the DS18B20 voltage, I did like the example and it works fine. My project isn't running all the day (yet), so I have no feedback for the moment.

Peter, you have found the library I used. I can't used the OLED library, because LCD screen and OLED screen are different kind of screen. The chips, and so the instructions are differents.

My screen is like that:
https://www.amazon.fr/dp/B00MODAKM4/ref ... w=g&hvqmt=

User avatar
PoltoS
Posts: 5682
Joined: 26 Jan 2011 19:36

Re: float conversion

Post by PoltoS »

To solve your problem with

Code: Select all

#define En B00000100 // Enable bit
#define Rw B00000010 // Read/Write bit
#define Rs B00000001 // Register select bit
you need to include Binary.h. This is because Bnnnnnnnn is not ANSI C form.

Oh, those lazy people from the Arduino world! An include file not to write the leading zero!

petergebruers
Posts: 248
Joined: 26 Jul 2015 17:29

Re: float conversion

Post by petergebruers »

@coco82 I recognize that type of display, I "bitbang" it on my arduino :-) Regarding injecting current into the pin of a microprocessor, if it is high enough the chip might latch-up and get destroyed. I have a certain Microchip mcu, and if you inject 1 mA on a digital pin then the ADC gets less accurate! So it always worries me to see 5V connected to a 3 V circuit...

@PoltoS I did not know about that Binary.h... And I like your style of humour :-)

schmidmi
Posts: 55
Joined: 01 Dec 2016 16:45
Location: Germany (Karlsruhe)

Re: float conversion

Post by schmidmi »

Maybe we have here the same problem, I saw while write an float to the OLED display with oled.print(...)?

petergebruers
Posts: 248
Joined: 26 Jul 2015 17:29

Re: float conversion

Post by petergebruers »

I think so, can you please have a look at this post for a workaround (printing two integers instead of a float):

viewtopic.php?f=3427&t=25514&start=20

Post Reply