Search found 888 matches

by Roberthh
Thu Apr 26, 2018 12:09 pm
Forum: Programs, Libraries and Tools
Topic: TypeError: can't convert bytearray to int
Replies: 1
Views: 13

Re: TypeError: can't convert bytearray to int

The second argument of i2c.readfrom_mem_into is expected to be an int, not an array. So no need to copy the address into a bytearry first.
by Roberthh
Thu Apr 19, 2018 3:27 pm
Forum: General Discussion and Questions
Topic: Help writing and reading files
Replies: 10
Views: 176

Re: Help writing and reading files

With you approach, the hint of @OutoftheBOTS_ seems more appropriate, to use plain text files. You can write you float to the file with f.write("%f\n" & float_number), and read that back with s = f.readline(), converting that back to float with float(s).
by Roberthh
Thu Apr 19, 2018 5:39 am
Forum: General Discussion and Questions
Topic: Help writing and reading files
Replies: 10
Views: 176

Re: Help writing and reading files

Could it be that you reached the end of the file, in which case readline() returns an empty string? Since unpack of "f" requires 4 bytes, the buffer, having a length of 0, is too small.
by Roberthh
Sun Apr 15, 2018 7:02 am
Forum: General Discussion and Questions
Topic: GPIO pin output works in REPL, not in main.py
Replies: 7
Views: 152

Re: GPIO pin output works in REPL, not in main.py

From all what I know and experienced, soft reset reruns boot.py and main.py, at least that is the intention. But it may happen that is is not executed. For instance if you run fro SD card, and the SD card is not properly initialized at soft reset. I never have seen that on a PyBoard, but quite often...
by Roberthh
Fri Apr 13, 2018 8:04 pm
Forum: General Discussion and Questions
Topic: Indentation character in a script
Replies: 7
Views: 122

Re: Indentation character in a script

I use indentation by spaces throughout all editors, which works well with all Python variants. I set my editors to replace Tab by spaces. Maybe you can check with hd or similar which characters are really in your scripts.
by Roberthh
Fri Apr 13, 2018 6:53 pm
Forum: General Discussion and Questions
Topic: GPIO pin output works in REPL, not in main.py
Replies: 7
Views: 152

Re: GPIO pin output works in REPL, not in main.py

I cannot answer that well, because I do not use rshell a lot. The setting of buffer-size=30 was mentioned in various posts as adequate. It is strange that the device does not reset after Ctrl-D in this simple GPIO test. I had that experience with WiFi & sockets, where had to go through hard reset to...
by Roberthh
Fri Apr 13, 2018 7:45 am
Forum: General Discussion and Questions
Topic: GPIO pin output works in REPL, not in main.py
Replies: 7
Views: 152

Re: GPIO pin output works in REPL, not in main.py

Looks not OK. You need a second pyb.delay() in the loop after the second pin.value(). Otherwise you will switch back too fast. That secopnd delay is there but commented out.
by Roberthh
Fri Apr 13, 2018 7:39 am
Forum: ESP32 boards
Topic: How calculate time.ticks_ms for long periods?
Replies: 6
Views: 114

Re: How calculate time.ticks_ms for long periods?

Yes, TICKS_MAX is the same for ticks_ms() and ticks_us(), but obviously the time span of TICKS_MAX milliseconds (~298 hours) is by a factor of 1000 long than TICKS_MAX microseconds (~18 Minutes); using ticks_diff() for the calculation.
by Roberthh
Wed Apr 11, 2018 5:51 am
Forum: ESP32 boards
Topic: How calculate time.ticks_ms for long periods?
Replies: 6
Views: 114

Re: How calculate time.ticks_ms for long periods?

rtc.datetime() will give a us resiltion time object. It is based on the same function ticks_ms uses.
try

Code: Select all

from machine import RTC
rtc=RTC()
rtc.datetime()
It returns a tuple with (year, month, day, hour, minute, second, µs)
by Roberthh
Wed Apr 04, 2018 11:00 am
Forum: The MicroPython pyboard
Topic: Non-latching relay fails to deactivate
Replies: 4
Views: 91

Re: Non-latching relay fails to deactivate

Looking at the board picture, it seems as if the relay coil is connected to GND on on side, and the transistor's collector is connected to Vcc. So I guess it needs a low level to activate and a high level to deactivate. if Vcc of the module is 4v, and Vin is ~3.3 V, then it's no surprise that is sta...