• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

using i2c to talk to a PIC processor from ESp32 via MicroPython

Q&A Forum › Category: ESP32 › using i2c to talk to a PIC processor from ESp32 via MicroPython
0 Vote Up Vote Down
vgershman asked 4 years ago

Hi,
 
I am trying to send data from a PIC processor to ESP32. I started sending out data from the PIC. In ESP32 i run i2c.scan, but it returns a number of i2c addresses. How do i know i2c address of ESP32? Is there a low level example on how to read data from external processor to ESP32 in Micropython?
 
Thanks

Question Tags: i2c, i2c.scan, MicroPython
5 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
So, you want to set the ESP32 as an I2C slave device, right?
According to this discussion, there isn’t I2C slave support on the official micropython distribution. But there is support in the loboris fork: https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/i2c
When creating an I2C instance, you can set the slave address.
Let me know it helps.
Regards,
Sara

0 Vote Up Vote Down
vgershman answered 4 years ago

Hello,
Thanks for the directions. Would ARDUINO allow setting ESP32 or ESP8266 as  a slave?
 
Thanks

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.

I don’t think it is implemented in Arduino IDE for the ESP32. At least I haven’t found any information about that.

You can set it as I2C slave using IDF: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/i2c.html

For the ESP8266, I’ve found this library: https://github.com/suculent/esp8266-I2C-slave

You can also consider using Serial communication instead, it is better documented (if it suits your project).

Regards,
Sara

0 Vote Up Vote Down
vgershman answered 4 years ago

Hi,
Still struggling with i2c :). i decided to use ESP32 as a master and use PIC as a slave. Your examples in  Micropython course kind of hide the low level i2c stuff. And the BME280 and OLED programs are too complicated to learn from. Is there some low level MicroPython  example of how to setup i2c to read data from a slave device? For example, if i have:
i2c = I2C(-1, scl=Pin(22), sda=Pin(21),freq=100000)
do i still need to run “i2c.start()”?
or when i run “i2c.readfrom(0x2c,1, True)”, i get an error:
OSError: [Errno 110] ETIMEDOUT
I would like to be able to constantly read from a slave even when it is not ready.
Thanks
 

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
I’ve found this Adafruit tutorial on how to use I2C with MicroPython:
https://learn.adafruit.com/micropython-hardware-i2c-devices/i2c-master
I think this may contain the information that you need.

To avoid that error, I think you need to use that I2C command inside a try and except statement, so that you keep trying to read I2C even when it is not ready.

I hope this helps.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.