I2C 4 U

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
mjf2708
Posts: 47
Joined: Sun Oct 07, 2012 8:37 am
Contact:

Re: I2C 4 U

Postby mjf2708 » Wed Jul 05, 2017 10:46 am

Well, thanks for that lengthy explanation, Martin, and taking the time to investigate! :)

I'm happy with the situation as it is, as my simple program works OK with all my samples of this module (3 HTU21D, 1 SHT21)
- it's just that when I first connected, the fact that *I2CQUERY showed nothing made think they weren't working...

Mike

User avatar
MartinB
Posts: 4671
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity
Contact:

Re: I2C 4 U

Postby MartinB » Wed Jul 05, 2017 12:31 pm

I mentioned using the response byte at &67 (detailed in the manual) and as an example, you could easily protect your test program from a broken or disconnected device with the addition of a generic line 35 as follows....

Code: Select all

   10  REM HTU21D / SHT21 relative humidity & temperature
   20  T%=&40
   30  *I2CTXB T% FE
   35  IF ?&67<>0 THEN PRINT "Device not found!" : END
   40  REM get humidity data
   50  *I2CTXB T% E5
   60  FORI%=1TO100:NEXT
   70  .......

User avatar
daveejhitchins
Posts: 4070
Joined: Wed Jun 13, 2012 5:23 pm
Location: Newton Aycliffe, County Durham
Contact:

Re: I2C 4 U

Postby daveejhitchins » Thu May 17, 2018 6:45 pm

Parts: UM6502CE, GAL22V10D, GAL16V8D, AS6C62256A, TC514400AZ, WD1772, R6522, TMS27C512, AT28C256
Products: ARA II, ABR, ATI, AP6, MGC, AP5 . . .
For a price list, contact me at: Retro Hardware AT dave ej hitchins DOT plus DOT com

User avatar
MartinB
Posts: 4671
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity
Contact:

Re: I2C 4 U

Postby MartinB » Thu May 17, 2018 9:21 pm

Ha! Thanks Dave, but being an I2C nerd, I have of course already got sensors for all of those parameters (and much more besides) since one of the nice things about I2C is that it is a bus and you can just daisy-chain any gadgets at will so you can also freely pick and mix your sensors. Actually, that’s quite expensive as I2C modules go, but perhaps it’s a reflection of the fact that it’s a 4-in-1. Personally, I just buy cheap Chinese modules from eBay or Banggood (5v ones for ease) and they always seem to work just fine.

All-in-all, it’s experimenter’s heaven and from what I’ve seen of the modern alternatives, a Beeb (or an Elk :wink: ) running my I2C rom with BBC Basic is much easier to use and way more fun than a Pi or Arduino etc. :D