USB data to Esp32

SeLoRBIS
Posts: 13
Joined: Sun Jan 21, 2018 11:51 pm

USB data to Esp32

Postby SeLoRBIS » Mon Jan 22, 2018 12:11 am

Hello,

I search to receive data from usb serial port of ESP32 dev board on send this data by WiFi to my "Domoticz Box" (via MQTT or another API)
I've all ready implement the MQTT and WiFi parts on the ESP32 side but i don't find how to get data from the micro USB port.
Actually I collect tele Information from my electric counter with this device :
http://gce-electronics.com/fr/usb/655-m ... o-usb.html

My wish is to connect this device to a ESP32 for sending data.

Have you any idea how i can do that ?

Many thanks

ESP_Sprite
Posts: 9051
Joined: Thu Nov 26, 2015 4:08 am

Re: USB data to Esp32

Postby ESP_Sprite » Mon Jan 22, 2018 1:40 am

Not with the micro-usb port on your devboard, for one. First of all, it's not connected to the ESP32 itself (which doesn't have the USB hardware for it) but to an USB-to-serial chip on the devboard. Secondly, this port is a device port; you can only use it to connect it to a host, not to another device like your module. There are USB-hostchips that are controlled over SPI (Maxim has a few, if memory serves) that you theoretically could use; chances are, however, that you're on your own wrt developing drivers.

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: USB data to Esp32

Postby rudi ;-) » Mon Jan 22, 2018 8:22 am

SeLoRBIS wrote:Hello,
I search to receive data from usb serial port of ESP32 dev board on send this data by WiFi to my "Domoticz Box" (via MQTT or another API)
did i right understand?:
your "Domoticz Box" receive over WiFi data from an ESP32 dev board.
the RAW data you want send by WiFi you want receive over the usb serial port of ESP32 dev board?
SeLoRBIS wrote:Hello,
I've all ready implement the MQTT and WiFi parts on the ESP32 side but i don't find how to get data from the micro USB port.
how you get data from the micro USB port of your ESP32 dev board?
which ESP32 dev board you use? do you mean the DevKitC ESP32 Board from espressi`?
SeLoRBIS wrote: Actually I collect tele Information from my electric counter with this device :
http://gce-electronics.com/fr/usb/655-m ... o-usb.html
this telemetric box use a FTDI USB IC that handle the communication between the box and a USB HOST,
the box is a USB Device.
taken from the system data:

- Driver FDTI pour Windows, Linux, MAC OS, Windows CE (Virtual Serial Port)
- Vitesse de communication 1200 Bauds, 7 bits, parité impaire, 1 stop.
SeLoRBIS wrote:
My wish is to connect this device to a ESP32 for sending data.

Have you any idea how i can do that ?
as the previous speaker mentioned,
it is not possible to connect this box ( USB Device ) to the mikro USB Adapter ( USB Device )
you need a USB Host or USB OTG.

you have couple of possibles way:

cause this telemtrie box as USB device works with a small baud ( 1200 bauds ) you can try to use
GPIO pins of ESP32 to make a USB HOST by Bit Bang

have a look in successful examples in other projects, how is it done:
here, there, any

if you not need to use "your ESP32 Dev Board" maybe you have a look to the ESP32-PRO board from olimex.


have a look:
Image

it has ESP32 on board, you can use it like your ESP32 dev board, and the ESP32-PRO has a USB DEVICE, USB OTG and USB HOST.
with the OTG and HOST functionally, you can connect your telemtrie box to the ESP32-PRO board and send your collect data over the WiFi to your "Domoticz Box" , how cool is that?

and if there are datas from telemetric and there is bad wifi or goes offline, you can collect your offline data to the SD-CARD
and later send it later ...

... you can connect the telemtry box directly on the ESP32-PRO micro USB,
you need an USB OTG cable for this, same cable that comes with phones if you want connect USB stick to your handy micro usb.

if you run in reserve with gpio and peripheral on ESP32 - you can use the gpio and interfaces of the PIC32 on the ESP32-PRO too,
simple in the arduino ide or professional with MPLAP X

maybe one or the other tip helps you with your further specifications.
have phun!

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: USB data to Esp32

Postby rudi ;-) » Mon Jan 22, 2018 8:49 am

..
only for completly:

you can use a third small cheap µController, that have USB HOST
on this you can connect an USB HUB
on this you can connect the ESP32 dev board and connect the telemtry box.

than you have to write a small USB HOST code / or use template code for the cheap µController with USB HOST functionally
and do only a forward function as transparent USB Serial to USB Serial

a cheap µController with USB HOST functionally starts lees half buck, 0.40 USD / peaces
if you need more info about this way, post your request and i post some examples

hope this helps
best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

SeLoRBIS
Posts: 13
Joined: Sun Jan 21, 2018 11:51 pm

Re: USB data to Esp32

Postby SeLoRBIS » Mon Jan 22, 2018 11:41 am

Hello, thanks for all your answers ! (It's weird i've post an answer but i doesn't see anything. Anyway I retry !)

For complete my initial question

What I actually have :

Electric counter -> GCE device -> RPI 3 with Domoticz

Input : A electric counter which send teleinfos data by two pins (i1, i2) to a device (GCE device) with two wires.
Output : USB cable to Raspberry Pi USB port
This GCE device collect data and send them by USB to my "Domoticz Box" : a Raspberry Pi 3 with a Domoticz docker container.
Domoticz receive, parse and diplay data on several graphs.

What I wish :

I want to replace the USB connection between the USB GCE teleinfo device, by a wireless connection, because actually I must put my RPI near the electric counter and I want to put Domoticz on a central place in my house.

What I understand :

I can't actually receive data from the micro USB port of the ESP32 dev board (DOIT ESP32 Devkit 1) because the data transfert speed is not the same and too low (1200 bds from the GCE device).
I've two solutions :
- Use a USB -> FDTI board like this for example (it's a board i have) :
https://www.ebay.com/itm/Serial-Convert ... 0290.m3507
- Make a USB Host on the dev board by code .

It's right ?

I'm looking your differents links.

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: USB data to Esp32

Postby rudi ;-) » Tue Jan 23, 2018 1:36 pm

SeLoRBIS wrote:
Input : A electric counter which send teleinfos data by two pins (i1, i2) to a device (GCE device) with two wires.
Output : USB cable to Raspberry Pi USB port
This GCE device collect data and send them by USB to my "Domoticz Box" : a Raspberry Pi 3 with a Domoticz docker container.
Domoticz receive, parse and diplay data on several graphs.
hi

can you short confirm, this is what you have, right?
overview_.png
overview_.png (10.41 KiB) Viewed 27115 times

and this is what you wish
wish_.png
wish_.png (12.48 KiB) Viewed 27115 times

can you say, what this GCE have as input? ( i1, i2 )
is this Uart connection? ( Tx, Rx )
or only a contact ( switcher ) and GCE counts and collect this data ?


best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: USB data to Esp32

Postby rudi ;-) » Tue Jan 23, 2018 2:26 pm

SeLoRBIS wrote:
What I understand :

I can't actually receive data from the micro USB port of the ESP32 dev board (DOIT ESP32 Devkit 1) because the data transfert speed is not the same and too low (1200 bds from the GCE device).
i must little edit:
first: you can setup the speed ( baud ) on ESP32 dev board (DOIT ESP32 Devkit 1)
this USB contact ( input, output ) is only a USB Device and on PC / USB HOST devices , this works as "Virtal Com (CDC ACM )"
see it like a FTDI USB TTL device with inputs Rx, Tx, and so on , and it transform to USB and vice versa.

this is not the reason for that, that you can't connect them.
the reason cause you can't connect them, is, that the GCE (with high probability) is a USB Device and the ESP32 dev board (DOIT ESP32 Devkit 1) micro connector is a USB Device.

only for 100 procent
supplementary question:
The GCE is connected to the RASP3 on the USB host, right?
Hence the assumption that the GCE is then also a USB device.
Please correct me if I take it wrong.

SeLoRBIS wrote:
I've two solutions :
- Use a USB -> FDTI board like this for example (it's a board i have) :
https://www.ebay.com/itm/Serial-Convert ... 0290.m3507
this FTDI UART TTL board transform TTL ( UART signal ) to USB and FTDI drives on PC / USB HOST this then as "Virtual COM" (CDC ACM)
you can only conect them (same) to a PC/USB Host
SeLoRBIS wrote:
- Make a USB Host on the dev board by code .

It's right ?

I'm looking your differents links.
i must ask back:
this GCE device - is this the telemetri device that you posted?
or is the counter the telemtrie device?
why i ask:

if the counter is the telemtrie device, and the wires ( i1, i2) are TTL / Uart
then you can check, with level ( 3V3, 5V, 12V ) they drive.
if they 3V3 example, you can use this as UART pins to the ESP32 dev board (DOIT ESP32 Devkit 1)
and make a transparent UART2Wifi ..
( if they are 5,12 or other you need level shifter, level converter )

if they only "contacts" you can try the same, if you trigger then GPIO on ESP32 DEV board
and make a custom firmware for it to count, collect and so on and forward the data then by ESP32 DEV board...

we need little more info, what are this lines are ( i1, i2 ) and what function they have.
or does they are CAN bus contacts? then you can use ESP32 DEV board too for forward, cause it support CAN bus
( you need a transceiver ic only for the lines )

can you go detailed with this questions, please.

possibles: ( GPIO, I2C, SPI, CAN, ....)
possible_CAN_ESP32-DEV.png
possible_CAN_ESP32-DEV.png (21.83 KiB) Viewed 27103 times
the other:
yes, if you make an USB host on the ESP32 DEV board then you can work with this data that comes from GCE.
the GCE is then USB CDC ACM ( USB Device ).

"ESP32 DEV Board"
sol1_USB_HOST_on_ESP32-DEV.png
sol1_USB_HOST_on_ESP32-DEV.png (20.21 KiB) Viewed 27107 times

ESP32-PRO
sol2_USB_HOST_on_ESP32-PRO.png
sol2_USB_HOST_on_ESP32-PRO.png (148.46 KiB) Viewed 27104 times

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: USB data to Esp32

Postby rudi ;-) » Tue Jan 23, 2018 5:02 pm

SeLoRBIS wrote: ..
- Make a USB Host on the dev board by code .
If you can prog it - yes - bit bang the code.
SeLoRBIS wrote:
I'm looking your differents links.
an further elegant way you can go with MAX3421E example too

USB Host shield and ESP8266 demos
you must then transform the esp8266 code like you want to esp32

in the past this other doing espusb was done on ESP8266 as USB device, you find example code here for your reference and background.


best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: USB data to Esp32

Postby rudi ;-) » Tue Jan 23, 2018 11:29 pm

hi

forget the way/thing suggestion with uart, spi on i1, i2.

the electric counter is no electric switch , it is a "Kilowatts compteur - compteur d'électricité" / "Kilowatts counter - electricity utility counter", non / right? and the GCE USB 655 device counts and collect, there is no datasheet on the web.

EDIT: there are many things on the GCE website and it seems this is a own protocol / special protocol, i could not find out, which protocol this is, perhabs if you have more information on this, you can post datasheet or likewise.

if you want conect this GCE device wireless, then you need a USB Host solution. ( USB Host Shield, ESP32-pro, MAX3421E ...)
total_USB_HOST_on_ESP32-DEV_ESP32-pro.png
total_USB_HOST_on_ESP32-DEV_ESP32-pro.png (236.52 KiB) Viewed 27025 times

btw:
would this be an alternate to you?
you can also measure, monitor and summarize the power consumption herewith. you can also connect to the ESP32 Dev board
and create a firmware for it. but that's just an alternative away suggestion to posttheme "USB Data to ESP32"

hope this helps
best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: USB data to Esp32

Postby rudi ;-) » Thu Jan 25, 2018 10:27 am

SeLoRBIS wrote:
I'm looking your differents links.

one more suggestion i have for you ( not cheap, not expensive, you must know this by your self ) ,
if you not want use other ESP32 Dev board.

here


Image

it is a simple USB Host, comes with prepaired Firmware, example for your CDC HOST as Class or an USB MODEM
and it looks like it is easy to handle with other USB HOST firmware's cause it has bootloader and
prepaired firmware for any uses.

Image


here is an basicly cheaper alternate to USB HOST Shield and other
this mini usb host adapter


personaly i did not test this for me, so feel free to update your thread if you have found your solution and successful work.

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Who is online

Users browsing this forum: No registered users and 269 guests